//
//  ZLViewController.m
//  ZLYoYoIM
//
//  Created by itzhaolei on 01/15/2021.
//  Copyright (c) 2021 itzhaolei. All rights reserved.
//

#import "ZLViewController.h"
#import "ZLTestSessionListViewController.h"
#import "ZLSessionLoginManager.h"

#define NIMMyAccount   @"8"
#define NIMMyToken     @"922411bf400fe2d5aac0aaae03a5c239"

@interface ZLViewController ()

@property (weak, nonatomic) IBOutlet UITextField *account;
@property (weak, nonatomic) IBOutlet UITextField *password;
@property (weak, nonatomic) IBOutlet UIButton *doneItem;

@end

@implementation ZLViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = UIColor.whiteColor;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Action
- (IBAction)doneItemAction:(UIButton *)sender {
    
    __weak typeof(self)weakSelf = self;
    
    //请将 NIMMyAccount 以及 NIMMyToken 替换成您自己提交到此App下的账号和密码
    [ZLSessionLoginManager login:NIMMyAccount token:NIMMyToken completion:^(NSError * _Nonnull error) {
        if (!error) {
            NSLog(@"登录成功");
            //创建会话列表页
            ZLTestSessionListViewController *vc = [[ZLTestSessionListViewController alloc] initWithNibName:nil bundle:nil];
            UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
            nav.navigationBar.hidden = YES;
            nav.modalPresentationStyle = UIModalPresentationFullScreen;
            [weakSelf addChildViewController:nav];
            [weakSelf.view addSubview:nav.view];
        }else{
            NSLog(@"登录失败");
        }
    }];
    
    
}

@end

